package com.fyi.controller;

import com.fyi.entity.ArticleType;
import com.fyi.service.ArticleTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/type")
public class ArticleTypeController {


    @Autowired
    private ArticleTypeService articleTypeService;

    @RequestMapping("ArticleManagerView")
    public String articleTypeView(){
        return "backView/articleManager";
    }

    @RequestMapping("articleManagerType")
    @ResponseBody
    public Map articleType(){
        List<ArticleType> selectAllType = articleTypeService.selectAllType();
        Map result = new HashMap();
        result.put("code", 200);
        result.put("msg", "查询成功");
        result.put("data", selectAllType);
        return result;
    }
    @RequestMapping("articleTypeId")
    @ResponseBody
    public Map articleTypeId(@PathVariable Integer id){
        ArticleType selectByTypeId = articleTypeService.selectByTypeId(id);
        Map result = new HashMap();
        result.put("code", 200);
        result.put("msg", "查询成功");
        result.put("data", selectByTypeId);
        return result;
    }
}
